<template>
  <div class="scrollbar-container">
    <div class="scrollbar__wrap scrollbar__wrap--hidden-default" ref="scrollbar__wrap">
      <slot></slot>
    </div>
  </div>
</template>

<script lang="ts">
import {defineComponent} from 'vue'

export default defineComponent({
  name: "Scrollbar",
  methods: {
    onTryScroll(pageX: number, scrollValue: number = 20) {
      const el = this.$refs['scrollbar__wrap'] as HTMLElement;
      if (el) {
        console.log(el.scrollLeft, el.scrollWidth, el.clientWidth, pageX)
      }
    }
  }
})
</script>

<style lang="less" scoped>
.scrollbar-container {
  overflow: hidden;
  position: relative;
  height: 100%;

  .scrollbar__wrap {
    overflow: auto;
    height: 100%;
  }

  .scrollbar__wrap--hidden-default {
    padding-bottom: 5px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    //滚动条整体
    &::-webkit-scrollbar {
      width: 8px; /*高宽分别对应横竖滚动条的尺寸*/
      height: 8px;
      display: none;
    }

    &:hover {
      &::-webkit-scrollbar {
        //display: block;
      }
    }

    //滚动条小方块
    &::-webkit-scrollbar-thumb {
      border-radius: 8px;
      background: #C7C9CC;
    }

    //滚动条轨道
    &::-webkit-scrollbar-track {
      border-radius: 8px;
    }
  }
}
</style>
